﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace XinKuaiJiInterface.Interface
{
    /// <summary>
    /// LoginInterface 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    // [System.Web.Script.Services.ScriptService]
    public class LoginInterface : System.Web.Services.WebService
    {

        [WebMethod]
        public string Login(string email, string pwd, string sign)
        {
            string jsonResult = "";
            List<Dictionary<string, object>> jsonList = new List<Dictionary<string, object>>();
            try
            {
                List<String> list = new List<string>();
                list.Add(email);
                list.Add(pwd);
                if (Util.checkSignSuccess(list, sign))
                {
                    Dictionary<string, object> dic = new Dictionary<string, object>();
                    dic.Add("RESPOSECODE", "000000");
                    dic.Add("RESPOSEMSG", "登录成功");
                    jsonList.Add(dic);                   
                }
            }
            catch (Exception e)
            {
                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic.Add("RESPOSECODE", "000001");
                dic.Add("RESPOSEMSG", "系统忙，请稍后重试。");
                if (jsonList.Count != 0)
                {
                    jsonList.Clear();
                }
                jsonList.Add(dic);
                Util.WriteLog(typeof(LoginInterface),e);
            }
            finally
            {
                jsonResult = Util.getJsonByObject(jsonList);
                //object o=Util.getObjectByJson(jsonResult, jsonList);                
            }
            return jsonResult;

        }
        [WebMethod]
        public bool Exists(long userId)
        {
            XinKuaiJi.BLL.t_user_info userInfo = new XinKuaiJi.BLL.t_user_info();
            return userInfo.Exists(userId);
        }
    }
}
